/*
 * @Author: tanjunyi@doctorwork.com
 * @Date: 2020-10-17 14:39:52
 * @LastEditors: tanjunyi@doctorwork.com
 * @LastEditTime: 2020-10-17 15:36:26
 * @Description: 自动回复机器人
 */
var request = require('request');
var urlencode = require('urlencode');

const baseUrl = 'http://api.qingyunke.com/api.php?key=free&appid=0&msg='

const autoReplay = (msg) => {
	const url = baseUrl + urlencode(msg);
	return new Promise(function (resolve, reject) {
		request(url, function (error, response, body) {
			if (!error && response.statusCode == 200) {
				var data = JSON.parse(body);

				resolve(data.content)
			}
		})

	})
}

module.exports = autoReplay;